<%@include file="_header.jspf" %>
<%@page import="com.spartancoder.accommodation.models.AuthToken" %>
<%@page import="com.spartancoder.accommodation.models.Administrator" %>
<%@page import="com.spartancoder.accommodation.beans.AdministratorBean" %>

<h2>Lista de conturi administrative</h2>
<table>
    <thead>
        <th>ID</th>
        <th>Nume</th>
        <th>Operatie</th>
    </thead>
    <tbody>
<%
AuthToken authToken = (AuthToken)request.getAttribute("authToken");
for( AdministratorBean ab : Administrator.fetchAll() ) {
%>
    <tr>
        <td><%=ab.getAdministratorId()%></td>
        <td><%=ab.getUser()%></td>
        <td>
            <% if(ab.getAdministratorId() != authToken.getId() ) { %>
                <a href="remove-admin.jsp?id=<%=ab.getAdministratorId()%>">sterge</a>
            <% } %>
            <a href="password-admin.jsp?id=<%=ab.getAdministratorId()%>">schimba parola</a>
        </td>
    </tr>
<% } %>
    </tbody>
</table>

<%@include file="_footer.jspf" %>